package com.qianfeng.sks.findingfood.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.lidroid.xutils.BitmapUtils;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.qianfeng.sks.findingfood.R;
import com.qianfeng.sks.findingfood.bean.ResultListchannelItem;

import java.util.List;

/**
 * Created by sks on 15-7-10.
 */
public class HeadAdapter extends AppBaseAdapter<ResultListchannelItem> {
    private BitmapUtils bitmapUtils;

    public HeadAdapter(Context context, List<ResultListchannelItem> list, BitmapUtils bitmapUtils) {
        super(context, list);
        this.bitmapUtils = bitmapUtils;
    }

    @Override
    public View getItemView(int position, View view, ViewGroup viewGroup) {
        ViewPagerHolder holder = null;
        if (view == null) {

            view = inflater.inflate(R.layout.item_head_layout, null);
            holder = new ViewPagerHolder(view);
            view.setTag(holder);
        } else {
            holder = (ViewPagerHolder) view.getTag();
        }

        bitmapUtils.display(holder.imageView, list.get(0).getChannelItem().get(position).getIcon());
        holder.textView.setText(list.get(0).getChannelItem().get(position).getChannelName());
        return view;
    }

    public static class ViewPagerHolder {
        @ViewInject(R.id.item_head_image)
        ImageView imageView;
        @ViewInject(R.id.item_head_textView)
        TextView textView;

        public ViewPagerHolder(View itemView) {
            ViewUtils.inject(this, itemView);
        }

    }
}
